package com.yeung.exam;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class 组成最大的数 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int ind = 0;
        String data[] = new String[count];
        while (ind < count)
            data[ind++] = sc.nextInt() + "";
        //
        Arrays.sort(data, new Comparator<String>() {
            @Override
            public int compare(String s1, String s2) {
                return -(s1 + s2).compareTo(s2 + s1);
            }
        });
        for (String datum : data) {
            System.out.print(datum + " ");
        }
    }
}
